package com.mallcloud.mall.app.config;

import cn.hutool.crypto.digest.HMac;
import cn.hutool.crypto.digest.HmacAlgorithm;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * 星光里立牌支付配置
 */
@Slf4j
@Data
@Component
@ConditionalOnProperty("const.pay.url")
@ConfigurationProperties(prefix = "const.pay")
public class XglQRCodePaymentConfig {

    private String url;
    private String mch_id;//由数据库获取
    private String key;
    private String notifyUrl;

    /**
     * sign
     *
     * @return
     */
    @Bean(name = "xglPayHmac")
    public HMac getHmac() {
        log.info("获取xgl HMac加密实例");
        return new HMac(HmacAlgorithm.HmacSHA256, key.getBytes());
    }

}
